<template>
    <div>
        <a href="/DocAdd">医生信息新增</a>
        <hr>
        <table class="table">
            <thead>
                <tr>
                    <td>医生编号</td>
                    <td>医生名称</td>
                    <td>医生头像</td>
                    <td>科室</td>
                    <td>创建日期</td>
                </tr>
            </thead>
            <tbody>
                <tr v-for="a in data">
                    <td>{{a.DocId}}</td>
                    <td>{{a.DocName}}</td>
                    <td><img :src="'https://localhost:7087/'+a.DocImg" style="height: 60px; width: 60px;"></td>
                    <td>{{a.DepName}}</td>
                    <td>{{moment(a.DocTime).format("YYYY-MM-DD")}}</td>
                </tr>
            </tbody>
        </table>

        一共{{page.zys}}页，一共{{page.zhs}}行，第{{cha.Pageindex}}页，每页{{cha.Pagesize}}行
        <input type="button" value="首页" @click="fy(1)">
        <input type="button" value="上一页" @click="fy(2)">

        <input v-for="a in page.zys" type="button" :value="a" @click="ym(a)">

        <input type="button" value="下一页" @click="fy(3)">
        <input type="button" value="尾页" @click="fy(4)">
        <select v-model="cha.Pagesize" @click="yrl">
            <option value="2">请选择</option>
            <option value="3">3</option>
            <option value="5">5</option>
            <option value="7">7</option>
            <option value="10">10</option>
        </select>

        <input type="text" v-model="cha.Pageindex"><input type="button" value="跳转" @click="tz">

    </div>
</template>

<script setup lang="ts">


import { ref ,onMounted} from 'vue';
import axios from 'axios';
import moment from 'moment';
onMounted(()=>{
    Show();
})
const yrl =()=>{
    Show()
}
const tz = ()=>{
    Show()
}
const ym = (vul:any)=>{
    cha.value.Pageindex = vul;
    Show()
}
const data = ref([{
    "DocId": 1,
      "DocName": "张飞",
      "DocImg": "/img/4552e194-d035-4f2d-9445-1311d4dbbce61.jpg",
      "DocTime": "2025-05-19T04:45:31.426",
      "DepId": 1,
      "DepName": "脑科"
}])

const cha  = ref({
    Pageindex:1,
    Pagesize:2
})
const page = ref({
    zys :0,
    zhs:0
})
const fy =(e:any)=>{
    if(e==1){
        cha.value.Pageindex=1;
        Show()
    }
    
    if(e==2){
        if(cha.value.Pageindex>1){
            cha.value.Pageindex-=1;
            Show()
        }
    }
    if(e==3){
        if(cha.value.Pageindex<page.value.zys){
            cha.value.Pageindex+=1;
            Show();
        }
    }



    if(e==4){
        cha.value.Pageindex=page.value.zys;
        Show()
    }
}


const Show = ()=>{
    axios.get('https://localhost:7087/api/Doctor/DocShow',{params:cha.value}).then(res=>{
        data.value = res.data.list;
        page.value.zhs = res.data.count;
        page.value.zys = Math.ceil(page.value.zhs/cha.value.Pagesize);
    })
}


</script>

<style scoped>

</style>